<%@ page pageEncoding="utf-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="version" content="v2007.03.06" /> 
		<meta http-equiv="content-type" content="text/html; charset=utf-8" />
		<title><fmt:message key="auth.title"/></title>
		<link href="styles/layout.css" rel="stylesheet" type="text/css" />
		<link href="styles/css.css" rel="stylesheet" type="text/css" />
		<style type="text/css">
			body {
				margin: 0px;
				padding: 0px;
				font-family: Arial, Helvetica, sans-serif;
				font-size: 12px;
				color: #000000;
				background-color: #FFFFFF;
			}
			
			td {
				font-size: 12px;
				word-break: break-all;
				word-wrap:break-word;
				height: 26;
			}
			
			img {
				border: 0px;
				clear: right;
			}
			
			input {
				font-family: Arial, Helvetica, sans-serif;
				font-size: 12px;
				color: #000000;
			}
			
			a:link {
				font-size: 12px;
				color: #003399;
				text-decoration: none;
			}
			a:visited {
				font-size: 12px;
				color: #003399;
				text-decoration: none;
			}
			a:active {
				font-size: 12px;
				color: #003399;
				text-decoration: none;
			}
			a:hover {
				font-size: 12px;
				color: #003399;
				text-decoration: underline;
			}

			.showTab {
				background-image: url('images/tab-2.jpg');
				color: white;
				font-weight: bold;
				cursor: default;
			}
			.hideTab {
				background-image: url('images/tab-1.jpg');
				color: gray;
				font-weight: normal;
				cursor: pointer;
			}
			
			.disableButton {
				cursor: default;
				filter: Alpha(Opacity=30);
			}
			.enableButton {
				cursor: pointer;
				filter: Alpha(Opacity=100);
			}
		</style>
		<script type='text/javascript' src='dwr/engine.js'></script>
		<script type='text/javascript' src='dwr/util.js'></script>
		<script type='text/javascript' src='dwr/interface/permissionRemote.js'></script>
		<script type='text/javascript' src='dwr/interface/roleRemote.js'></script>
		<script type="text/javascript">
			function MM_preloadImages() { //v3.0
			  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
			    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
			    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
			}
			
			function MM_openBrWindow(theURL,winName,features) { //v2.0
			  window.open(theURL,winName,features);
			}
			
			var searchName = "";
			var searchRole = true;
			var searchPage = 0;
			var totalPage = 0;
			
			function initPage() {
				searchName = "";
				searchRole = true;
				searchPage = 0;
				showPage();
			}
			
			function search() {
				var sk = document.getElementById("searchKeyword").value;
				if (searchName != sk) {
					searchName = sk;
					searchPage = 0;
					showPage();
				}
			}
			
			function firstPage() {
				searchPage = 0;
				showPage();
			}
			
			function previousPage() {
				if (totalPage > 0 && searchPage > 0) {
					searchPage = searchPage - 1;
					showPage();
				}
			}
			
			function nextPage() {
				if (totalPage > 0 && searchPage < totalPage - 1) {
					searchPage = searchPage + 1;
					showPage();
				}
			}
			
			function lastPage() {
				searchPage = totalPage - 1;
				showPage();
			}
			
			function showPage() {
				roleRemote.searchByName(searchRole, searchName, searchPage, showPageCallback);
			}
			
			function showPageCallback(result) {
				if (result == null) {
					return;
				}
				searchPage = result.currentPage;
				totalPage = result.totalPage;
				document.getElementById("pageIndex").innerText = searchPage + 1;
				document.getElementById("pageTotal").innerText = totalPage;
				document.getElementById("firstPageButton").className = (searchPage == 0 ? "disableButton" : "enableButton");
				document.getElementById("previousPageButton").className = (searchPage == 0 ? "disableButton" : "enableButton");
				document.getElementById("nextPageButton").className = (searchPage == totalPage - 1 ? "disableButton" : "enableButton");
				document.getElementById("lastPageButton").className = (searchPage == totalPage - 1 ? "disableButton" : "enableButton");
				var roles = result.list;
				for (var i = 0; i <= 9; i = i + 1) {
					if (roles != null && i < roles.length) {
						var id = DWRUtil._getValueFrom(roles[i], "id");
						var name = DWRUtil._getValueFrom(roles[i], "name");
						document.getElementById("pageRowValue" + i).value = id;
						document.getElementById("pageRowContent" + i).innerText = name;
						document.getElementById("pageRow" + i).style.display = ("");
					} else {
						document.getElementById("pageRow" + i).style.display = ("none");
					}
				}
			}
			
			function showTab(isShow) {
				if (isShow) {
					document.getElementById("tabPane").style.display = ("");
					document.getElementById("tabCollapse").style.display = ("");
					document.getElementById("tabExpand").style.display = ("none");
					$("insideView").style.width = 630;
				} else {
					document.getElementById("tabPane").style.display = ("none");
					document.getElementById("tabCollapse").style.display = ("none");
					document.getElementById("tabExpand").style.display = ("");
					$("insideView").style.width = 845;
				}
			}
			
			function changeTab(isRole) {
				if (isRole == searchRole) {
					return;
				}
				if (isRole) {
					document.getElementById("roleTab").className = "showTab";
					document.getElementById("userTab").className = "hideTab";
					document.getElementById("searchTitle").innerText = "<fmt:message key='auth.role.name' />";
					document.getElementById("listTitle").innerText = "<fmt:message key='auth.role.name' />";
				} else {
					document.getElementById("roleTab").className = "hideTab";
					document.getElementById("userTab").className = "showTab";
					document.getElementById("searchTitle").innerText = "<fmt:message key='auth.user.name' />";
					document.getElementById("listTitle").innerText = "<fmt:message key='auth.user.name' />";
				}
				document.getElementById("searchKeyword").value = "";
				document.getElementById("searchKeyword").focus();
				searchName = "";
				searchRole = isRole;
				searchPage = 0;
				showPage();
			}
			
			//get rights by users or roles
			function changePrincipal(row) {
				var isRole = searchRole; 
				var id = document.getElementById("pageRowValue" + row).value; 
				var name = document.getElementById("pageRowContent" + row).innerText; 
				
				document.getElementById("isRole").value = isRole;
				document.getElementById("toId").value = id;
				document.getElementById("toName").value = name;
				if (isRole) {
					document.getElementById("authTo").innerText = "<fmt:message key="auth.role" />: " + name;
				} else {
					roleRemote.findRolesByUser(id, findRolesCallback);
				}
				initPermission();
				permissionRemote.getAllowSubjects(isRole, id, function(subjects) {
					setupSubjects(subjects, false);
					permissionRemote.getInheritAllowSubjects(isRole, id,  function(subjects) {
						setupSubjects(subjects, true);
					});
				});
			}
			
			function findRolesCallback(roles) {
				var s = "<fmt:message key="auth.user" />: " + document.getElementById("toName").value;
				if (roles != null && roles != "") {
					s = s + " (" + roles + ") ";
				}
				document.getElementById("authTo").innerText = s;
			}
			
			function setupSubjects(subjectString, isDisabled) {
			  	var subjects = subjectString.split(",");
				if (subjects != null && subjects.length > 0) { 
					for (var i = 0; i < subjects.length; i = i + 1) {
						var subject = subjects[i].split(":");
						if (subject != null && subject.length == 2) {
							var id = subject[0];
							var prefix = ("true" == subject[1] ? "function" : "handle");
							var prefixName = $(prefix + id);
							if(null != prefixName){
								prefixName.checked = true;
								prefixName.value = "true";
								prefixName.disabled = (isDisabled ? "disabled" : "");
							}
						}
					}
				}
			}
			
			function changePermission(id) {
				var chk = $(id);
				if (document.getElementById("toId").value == "") {
					chk.checked = (chk.value == "true")
					alert("<fmt:message key="auth.no.choose.alert" />");
					return ;
				}
				if (chk.checked != (chk.value == "true")) {
					$(id + "Back").style.backgroundColor = "red";
				} else {
					$(id + "Back").style.backgroundColor = "white";
				}
			}
			
			function initPermission() {
				initCheckBox("functions");
				initCheckBox("handles");
			}
			
			function initCheckBox(name) {
				var chks = document.getElementsByName(name);
			 	for (var i = 0; i < chks.length; i++) {
					chks[i].checked = false;
					chks[i].value = "false";
					chks[i].disabled = "";
					$(chks[i].id + "Back").style.backgroundColor = "white";
				}
			}
			
			function savePermission() {
				 
				if (document.getElementById("toId").value == "") {
					alert("<fmt:message key="auth.no.choose.alert" />");
					return ;
				}
				var isRole = (document.getElementById("isRole").value == "true");
				var id = document.getElementById("toId").value;
				var functionChanges = findChanges("functions");
				var handleChanges = findChanges("handles");
				var changes = functionChanges + handleChanges;
				if (changes == "") {
					alert("<fmt:message key="auth.no.changed.alert" />");
					return ;
				}
				permissionRemote.savePermissions(isRole, id, functionChanges + handleChanges, savePermissionCallback);
			}
			
			function savePermissionCallback(result) {
				if (result) {
					var isRole = (document.getElementById("isRole").value == "true");
					var id = document.getElementById("toId").value;
					var name = document.getElementById("toName").value;
					clearPermissionTag();
					alert("<fmt:message key="auth.success.alert" />");
				} else {
					alert("<fmt:message key="auth.failure.alert" />");
				}
			}
			
			function clearPermissionTag() {
				clearCheckboxTag("functions");
				clearCheckboxTag("handles");
			}
			
			function clearCheckboxTag(name) {
				var chks = document.getElementsByName(name);
			 	for (var i = 0; i < chks.length; i++) {
			 		if (chks[i].checked != (chks[i].value == "true")) {
			 			chks[i].value = (chks[i].checked ? "true" : "false");
			 			$(chks[i].id + "Back").style.backgroundColor = "white";
			 		}
				}
			}
			
			function findChanges(name) {
				var changes = "";
				var chks = document.getElementsByName(name);
			 	for (var i = 0; i < chks.length; i++) {
			 		if (chks[i].checked != (chks[i].value == "true")) {
			 			changes = changes + chks[i].id + ":" + chks[i].checked + ";";
			 		}
				}
				return changes;
			}
			
			function chooseAll() {
				if (document.getElementById("toId").value == "") {
					alert("<fmt:message key="auth.no.choose.alert" />");
					return ;
				}
				chooseAllCheckBox("functions", true);
				chooseAllCheckBox("handles", true);
			}
			
			function clearAll() {
				if (document.getElementById("toId").value == "") {
					alert("<fmt:message key="auth.no.choose.alert" />");
					return ;
				}
				chooseAllCheckBox("functions", false);
				chooseAllCheckBox("handles", false);
			}
			
			function chooseAllCheckBox(name, isChoose) {
				var chks = document.getElementsByName(name);
			 	for (var i = 0; i < chks.length; i++) {
			 		if (chks[i].checked != isChoose) {
			 			chks[i].checked = isChoose;
			 			changePermission(chks[i].id);
			 		}
				}
			}
			
			function reverseAll() {
				if (document.getElementById("toId").value == "") {
					alert("<fmt:message key="auth.no.choose.alert" />");
					return ;
				}
				reverseAllCheckBox("functions");
				reverseAllCheckBox("handles");
			}
			
			function reverseAllCheckBox(name) {
				var chks = document.getElementsByName(name);
			 	for (var i = 0; i < chks.length; i++) {
			 		chks[i].checked = (! chks[i].checked);
			 		changePermission(chks[i].id);
				}
			}
			
			function revertAll() {
				if (document.getElementById("toId").value == "") {
					alert("<fmt:message key="auth.no.choose.alert" />");
					return ;
				}
				revertAllCheckBox("functions");
				revertAllCheckBox("handles");
			}
			
			function revertAllCheckBox(name) {
				var chks = document.getElementsByName(name);
			 	for (var i = 0; i < chks.length; i++) {
			 		var state = (chks[i].value == "true");
			 		if (chks[i].checked != state) {
			 			chks[i].checked = state;
			 			$(chks[i].id + "Back").style.backgroundColor = "white";
			 		}
				}
			}
			
		</script>
	</head>
	<body onload="initPage();document.getElementById('searchKeyword').focus();">
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
			<tr>
				<td align="left" valign="top">
					<table width="100%" border="0" cellpadding="0" cellspacing="0">
						<tr>
							<td valign="top">
								<table width="100%" border="0" cellspacing="0" cellpadding="0">
									<tr>
										<td width="100%" class="home-content-title">
											<table width="100%" border="0" cellspacing="0" cellpadding="0">
												<tr>
													<td>
														<img src="images/home_ico_listTitle.gif" width="22" height="20" align="absmiddle">
														<fmt:message key="auth.title"/>
													</td>
												</tr>
											</table>
										</td>
									</tr>
									<tr>
										<td align="left">
											<table width="100%" border="0" cellpadding="0" cellspacing="0">
												<tr>
													<td width="75%" align="left" class="home-table-tool-content">
														<table width="100%" border="0" cellspacing="0" cellpadding="0">
															<tr>
																<td width="2%">
																	
																</td>
																<td width="78%" valign="bottom">
																	<table border="0" cellspacing="0" cellpadding="0" class="searchtitle">
																		<tr>
																			<td>
																				<table border="0" cellspacing="0" cellpadding="0" onclick="savePermission()" style="cursor: pointer;">
																					<tr>
																						<td width="15">
																						 <input name="Submit1" type="button" class="home-inputBtn" value="保存" />
																						</td>
																					</tr>
																				</table>
																			</td>
																			<td width="7" class="but_kong">
																				&nbsp;
																			</td>
																			<td>
																				<table border="0" cellspacing="0" cellpadding="0" onclick="chooseAll()" style="cursor: pointer;">
																					<tr>
																						<td width="15">
																						 <input name="Submit1" type="button" class="home-inputBtn" value="全选" />
																						</td>
																					</tr>
																				</table>
																			</td>
																			<td width="7" class="but_kong">
																				&nbsp;
																			</td>
																			<td>
																				<table border="0" cellspacing="0" cellpadding="0" onclick="clearAll()" style="cursor: pointer;">
																					<tr>
																						<td width="15">
																						 <input name="Submit1" type="button" class="home-inputBtn" value="全清" />
																						</td>
																					</tr>
																				</table>
																			</td>
																			<td width="7" class="but_kong">
																				&nbsp;
																			</td>
																			<td>
																				<table border="0" cellspacing="0" cellpadding="0" onclick="reverseAll()" style="cursor: pointer;">
																					<tr>
																						<td width="15">
																						 <input name="Submit1" type="button" class="home-inputBtn" value="反选" />
																						</td>
																					</tr>
																				</table>
																			</td>
																			<td width="7" class="but_kong">
																				&nbsp;
																			</td>
																			<td>
																				<table border="0" cellspacing="0" cellpadding="0" onclick="revertAll()" style="cursor: pointer;">
																					<tr>
																						<td width="15">
																						 <input name="Submit1" type="button" class="home-inputBtn" value="还原" />
																						</td>
																					</tr>
																				</table>
																			</td>
																		</tr>
																	</table>
																</td>
																<td width="30%" align="right" valign="top">
																	<table id="tabExpand" border="0" cellspacing="0" cellpadding="0" style="cursor: pointer; display: none;" onclick="showTab(true)">
																		<tr>
																			<td><img src="images/cel_left.gif" border="0" /></td>
																			<td class="blue12"><fmt:message key="auth.expand" /></td>
																		</tr>
																	</table>
																</td>
															</tr>
														</table>
													</td>
													<td id="tabPane" width="25%" rowspan="3" valign="top" class="bluebg_whiteLeftTopline" style="display: ;">
														<table width="100%" border="0" cellspacing="0" cellpadding="0">
															<tr>
																<td colspan="3" width="100%" align="left" valign="top">
																	<table id="tabCollapse" border="0" cellspacing="0" cellpadding="0" style="cursor: pointer; display: ;" onclick="showTab(false)">
																		<tr>
																			<td class="blue12"><fmt:message key="auth.collapse" /></td>
																			<td><img src="images/cel_right.gif" border="0" /></td>
																		</tr>
																	</table>
																</td>
															</tr>
															<tr>
																<td width="3%">
																	&nbsp;
																</td>
																<td width="91%" valign="top">
																	<table width="158" border="0" cellspacing="0" cellpadding="0">
																		<tr>
																			<td id="roleTab" width="79" height="28" align="center" valign="bottom" class="showTab" onclick="changeTab(true);">
																				<table width="100%" border="0" cellspacing="0" cellpadding="0">
																					<tr>
																						<td height="16" align="center" valign="top">
																							<fmt:message key="auth.role" />
																						</td>
																					</tr>
																				</table>
																			</td>
																			<td id="userTab" align="center" valign="bottom" class="hideTab" onclick="changeTab(false);">
																				<table width="100%" border="0" cellspacing="0" cellpadding="0">
																					<tr>
																						<td height="16" align="center" valign="top">
																							<fmt:message key="auth.user" />
																						</td>
																					</tr>
																				</table>
																			</td>
																		</tr>
																	</table>
																</td>
																<td width="3%">
																	&nbsp;
																</td>
															</tr>
															<tr>
																<td>
																	&nbsp;
																</td>
																<td align="left" valign="top" class="whiteBG_blueborder">
																	<table width="100%" border="0" cellspacing="0" cellpadding="0">
																		<tr>
																			<td width="3%">
																				&nbsp;
																			</td>
																			<td>
																				&nbsp;
																			</td>
																			<td width="3%">
																				&nbsp;
																			</td>
																		</tr>
																		<tr>
																			<td>
																				&nbsp;
																			</td>
																			<td align="right" class="black12">
																				<table border="0" cellpadding="0" cellspacing="0">
																					<tr>
																						<td>
																							<span id="searchTitle"><fmt:message key="auth.role.name" /></span>
																						</td>
																						<td>
																							<input type="text" id="searchKeyword" name="searchKeyword" size="8" style="width: 60px;" onkeypress="if (event.keyCode==13) search();" />
																						</td>
																						<td>
																							<table border="0" cellspacing="0" cellpadding="0" style="cursor: pointer;" onclick="search();">
																								<tr>
																									<td width="8" align="left" style="background-image: url('images/bu_bg_2.jpg');"><img src="images/bu_bg_1.jpg" width="8" height="22" /></td>
																									<td align="center" class="button-12-brown" style="background-image: url('images/bu_bg_2.jpg');"><fmt:message key="button.search" /></td>
																									<td width="8" align="right" style="background-image: url('images/bu_bg_2.jpg');"><img src="images/bu_bg_3.jpg" width="8" height="22" /></td>
																								</tr>
																							</table>
																						</td>
																					</tr>
																				</table>
																			</td>
																			<td class="black12">
																				&nbsp;
																			</td>
																		</tr>
																		<tr>
																			<td>
																				&nbsp;
																			</td>
																			<td>
																				<table width="96%" border="0" cellspacing="2" cellpadding="0">
																					<tr>
																						<td>
																							&nbsp;
																						</td>
																						<td>
																							&nbsp;
																						</td>
																					</tr>
																					<tr>
																						<td width="20%" height="23" align="center" bgcolor="#CCCCCC">
																							<fmt:message key="label.sort" />
																						</td>
																						<td width="80%" align="left" bgcolor="#CCCCCC">
																							<span id="listTitle"><fmt:message key="auth.role.name" /></span>
																						</td>
																					</tr>
																					<c:forEach var="row" begin="0" end="9">
																					<tr id="pageRow<c:out value="${row}"/>">
																						<td align="center" bgcolor="#E4E4E4">
																							<c:out value="${row + 1}"/>
																						</td>
																						<td>
																							<span id="pageRowContent<c:out value="${row}"/>" style="cursor: pointer; text-decoration: underline; color: #003399;" onclick="changePrincipal(<c:out value="${row}"/>);"></span>
																							<input type="hidden" id="pageRowValue<c:out value="${row}"/>" name="pageRowValue<c:out value="${row}"/>" value="" />
																						</td>
																					</tr>
																					</c:forEach>
																				</table>
																			</td>
																			<td>
																				&nbsp;
																			</td>
																		</tr>
																		<tr>
																			<td>
																				&nbsp;
																			</td>
																			<td>
																				&nbsp;
																			</td>
																			<td>
																				&nbsp;
																			</td>
																		</tr>
																		<tr>
																			<td>
																				&nbsp;
																			</td>
																			<td>
																				<table width="100%" border="0" cellspacing="0" cellpadding="0">
																					<tr>
																						<td align="right" class="blue12">
																							<span id="pageIndex" class="blue12B">0</span> / <span id="pageTotal">0</span>
																						</td>
																						<td width="28" align="left" class="blue12">
																							&nbsp;
																						</td>
																						<td width="20" align="left">
																							<img id="firstPageButton" src="images/first.gif" width="16" height="15" onclick="firstPage()" class="disableButton" />
																						</td>
																						<td width="20" align="left">
																							<img id="previousPageButton" src="images/pre.gif" width="16" height="15" onclick="previousPage()" class="disableButton" />
																						</td>
																						<td width="20" align="left">
																							<img id="nextPageButton" src="images/next.gif" width="16" height="15" onclick="nextPage()" class="disableButton" />
																						</td>
																						<td width="20" align="left">
																							<img id="lastPageButton" src="images/last.gif" width="16" height="15" onclick="lastPage()" class="disableButton" />
																						</td>
																					</tr>
																				</table>
																			</td>
																			<td>
																				&nbsp;
																			</td>
																		</tr>
																		<tr>
																			<td>
																				&nbsp;
																			</td>
																			<td>
																				&nbsp;
																			</td>
																			<td>
																				&nbsp;
																			</td>
																		</tr>
																	</table>
																</td>
																<td>
																	&nbsp;
																</td>
															</tr>
															<tr>
																<td>
																	&nbsp;
																</td>
																<td>
																	&nbsp;
																</td>
																<td>
																	&nbsp;
																</td>
															</tr>
														</table>
													</td>
												</tr>
												<tr>
													<td height="23" align="left" valign="top" class="bluebg">
														<table width="100%" border="0" cellspacing="0" cellpadding="0">
															<tr>
																<td width="1%">
																	
																</td>
																<td width="57%" class="blue12" align="left">
																	<table border="0" cellpadding="0" cellspacing="0">
																		<tr>
																			<td>
																				<img border="0" src="images/lendto.gif"/>
																			</td>
																			<td width="5"></td>
																			<td>
																				<fmt:message key="auth.to" />
																			</td>
																			<td width="5"></td>
																			<td id="authTo">
																			</td>
																			<td>
																				<input type="hidden" id="isRole" name="isRole" value="true" />
																				<input type="hidden" id="toId" name="toId" value="" />
																				<input type="hidden" id="toName" name="toName" value="" />
																			</td>
																		</tr>
																	</table>
																</td>
																<td width="37%" class="blue12" align="right">
																	<!-- 
																	<table border="0" cellpadding="0" cellspacing="0">
																		<tr>
																			<td>
																				<img border="0" src="images/role.gif"/>
																			</td>
																			<td width="5"></td>
																			<td>
																				<fmt:message key="auth.my.role" />: Admin
																			</td>
																		</tr>
																	</table>
																	-->
																</td>
																<td width="3%">
																	&nbsp;
																</td>
															</tr>
														</table>
													</td>
												</tr>
												<tr>
													<td id="outsideView" align="left" valign="top">
														<div id="insideView" style="width:638px; height: 380px; overflow: auto;">
														<table border="0" cellspacing="0" cellpadding="0" style="width: 1200px;">
															<tr align="center" style="background-image: url('images/listbg.gif');">
																<td valign="bottom" class="blue12">
																	<table width="100%" border="0" cellspacing="0" cellpadding="0">
																		<tr>
																			<td height="32" class="blue12">
																				<fmt:message key="auth.view" />
																			</td>
																		</tr>
																	</table>
																</td>
																<td width="4" align="left">
																	<img src="images/list-gx.gif" width="4" height="40" />
																</td>
																<td valign="bottom" class="blue12">
																	<table width="100%" border="0" cellspacing="0" cellpadding="0">
																		<tr>
																			<td height="32" class="blue12">
																				<fmt:message key="auth.menu" />
																			</td>
																		</tr>
																	</table>
																</td>
																<td width="4" align="left">
																	<img src="images/list-gx.gif" width="4" height="40" />
																</td>
																<td valign="bottom" class="blue12">
																	<table width="100%" border="0" cellspacing="0" cellpadding="0">
																		<tr>
																			<td height="32" class="blue12">
																				<fmt:message key="auth.function" />
																			</td>
																		</tr>
																	</table>
																</td>
																<!-- 
																<td width="4" align="left">
																	<img src="images/list-gx.gif" width="4" height="40" />
																</td>
																<td valign="bottom" class="blue12">
																	<table width="100%" border="0" cellspacing="0" cellpadding="0">
																		<tr>
																			<td height="32" class="blue12">
																				<fmt:message key="auth.scope" />
																			</td>
																		</tr>
																	</table>
																</td>
																-->
																<c:forEach var="handleType" items="${applicationScope.handleTypes}">
																	<td width="4" align="left">
																		<img src="images/list-gx.gif" width="4" height="40" />
																	</td>
																	<td valign="bottom" class="blue12">
																		<table width="100%" border="0" cellspacing="0" cellpadding="0">
																			<tr>
																				<td height="32" class="blue12">
																					<c:out value="${handleType.name}"/>
																				</td>
																			</tr>
																		</table>
																	</td>
																</c:forEach>
															</tr>
																<c:forEach var="menu" items="${applicationScope.handlesTree}" varStatus="menuStatus">
																	<tr align="center">
																		<td id="function<c:out value="${menu.id}"/>Back" class="line_xuxian">
																			<input type="checkbox" id="function<c:out value="${menu.id}"/>" name="functions" value="false" onclick="changePermission(this.id)" />
																		</td>
																		<td class="line_xuxian">
																			&nbsp;
																		</td>
																		<td class="line_xuxian" align="left">
																			<!-- 
																			<img border="0" src="images/open.gif" />
																			-->
																			<c:out value="${menu.name}"/>
																		</td>
																		<td class="line_xuxian">
																			&nbsp;
																		</td>
																		<td class="line_xuxian">
																			&nbsp;
																		</td>
																		<!-- 
																		<td class="line_xuxian">
																			&nbsp;
																		</td>
																		<td class="line_xuxian">
																			<select name="datascope1">
																				<option value="0"><fmt:message key="auth.scope.all" /></option>
																				<option value="1"><fmt:message key="auth.scope.province" /></option>
																				<option value="2"><fmt:message key="auth.scope.city" /></option>
																				<option value="3"><fmt:message key="auth.scope.department" /></option>
																			</select>
																		</td>
																		-->
																		<c:forEach var="handleType" items="${applicationScope.handleTypes}">
																			<td class="line_xuxian">
																				&nbsp;
																			</td>
																			<td class="line_xuxian">
																				&nbsp;
																			</td>
																		</c:forEach>
																	</tr>
																	<c:if test="${menu.childs != null}">
																	<c:forEach var="function" items="${menu.childs}" varStatus="functionStatus">
																		<tr align="center">
																			<td id="function<c:out value="${function.id}"/>Back" class="line_xuxian">
																				<input type="checkbox" id="function<c:out value="${function.id}"/>" name="functions" value="false" onclick="changePermission(this.id)" />
																			</td>
																			<td class="line_xuxian">
																				&nbsp;
																			</td>
																			<td class="line_xuxian">
																				&nbsp;
																			</td>
																			<td class="line_xuxian">
																				&nbsp;
																			</td>
																			<td class="line_xuxian" align="left">
																				<!-- 
																				<img border="0" src="images/ico_blk.gif" />
																				-->
																				<c:out value="${function.name}"/>
																			</td>
																			<!-- 
																			<td class="line_xuxian">
																				&nbsp;
																			</td>
																			<td class="line_xuxian">
																				<select name="datascope1">
																					<option value="0"><fmt:message key="auth.scope.all" /></option>
																					<option value="1"><fmt:message key="auth.scope.province" /></option>
																					<option value="2"><fmt:message key="auth.scope.city" /></option>
																					<option value="3"><fmt:message key="auth.scope.department" /></option>
																				</select>
																			</td>
																			-->
																			<c:forEach var="handle" items="${function.childs}">
																				<td class="line_xuxian">
																					&nbsp;
																				</td>
																				<td id="handle<c:out value="${handle.id}"/>Back" class="line_xuxian">
																					<c:if test="${handle.support}">
																						<input type="checkbox" id="handle<c:out value="${handle.id}"/>" name="handles" value="false" onclick="changePermission(this.id)"/>
																					</c:if>
																					<c:if test="${! handle.support}">
																						<img src="images/nonsupport.gif" border="0" />
																					</c:if>
																				</td>
																			</c:forEach>
																		</tr>
																	</c:forEach>
																	</c:if>
																</c:forEach>
														</table>
														</div>
													</td>
												</tr>
											</table>
										</td>
									</tr>
								</table>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
	</body>
</html>
